package cn.tx.erp.bus.controller;

import cn.tx.erp.bus.domain.Goods;
import cn.tx.erp.bus.service.GoodsService;
import cn.tx.erp.bus.vo.GoodsVo;
import cn.tx.erp.sys.utils.DataGridView;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Mxb
 * @version 1.0
 * @date 2020/7/12 16:38
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    /**
     * 查询所有的商品
     * @param goodsVo
     * @return
     */
    @RequestMapping("/loadAllGoods")
    public DataGridView loadAllGoods(GoodsVo goodsVo){
        // 分页
        IPage<Goods> page = new Page<>(goodsVo.getPage(),goodsVo.getLimit());
        // 条件
        QueryWrapper<Goods> qw = new QueryWrapper<>();
        //qw.like(StringUtils.isNotBlank(goodsVo.getCustomername()), "customername", customerVo.getCustomername());
        qw.orderByAsc("id");

        this.goodsService.page(page,qw);

        return new DataGridView(0,"",page.getTotal(),page.getRecords());
    }
}
